package vip.meeet;

import com.alibaba.fastjson.JSONObject;
import vip.meeet.utils.HttpUtil;

import java.io.IOException;

public final class EsHelper {

    /**
     * 节点状态查看
     */
    private static final String nodes_stats_url =  "http://%s/_nodes/stats/indices/search";
    /**
     * 节点设置
     */
    private static final String indices_setting_url =  "http://%s/_settings";

    /**
     * 127.0.0.1:9200 index_name
     * 指定索引节点配置
     */
    private static final String index_setting_url =  "http://%s/%s/_settings";

    /**
     * 指定索引分片信息
     */
    private static final String index_shards_url =  "http://%s/%s/_search_shards";

    public static String clusterSetting(String host,String settingJson) throws IOException {
        String urlBase = "http://%s/_cluster/settings/";
        String url = String.format(urlBase,host);
        return HttpUtil.putJsonContent(url,settingJson);
    }

    public static JSONObject getDefaultSettings(){
        JSONObject settings = new JSONObject();
        settings.put("number_of_shards",3);
        settings.put("number_of_replicas",1);
        settings.put("refresh_interval","30s");
        return settings;
    }



}
